#pragma once
// Copyright (c) WanSheng Intelligent Corp. All rights reserved.
// Licensed under the LGPL v3.0 license. 
using namespace std;
#ifndef __OPCUA_PLUGIN_H__
#define __OPCUA_PLUGIN_H__
#define LOG_TAG "OPCUA"
#include <stdlib.h>
#include "open62541.h"
#include <linux/prctl.h>
#include "path.h"
#include "ams_constants.h"

#include "plugin_constants.h"
#include "agent_core_lib.h"
#include "parson.h"
#include "er-coap.h"
#include "er-coap-constants.h"
#include "string_parser.h"
#include "logs.h"
#include "parson_ext.h"
#include "modbus_coding.h"
#include "cJSON_ext.h"
#include "wa_edge_types.h"
#include "wa_plugin_sdk.h"
#include "wa_bus.h"

#include <string>

#define PLUGIN_NAME "opcua_plugin"
#define MAX_OPCUA_DEVICE 50

typedef enum
{
	T_Invalid_DataType = -1,
	T_Bits = 0,
	T_int8,
	T_Uint8,
	T_int16,
	T_Uint16,
	T_int32,
	T_Uint32,
	T_Float,
	T_int64,
	T_Uint64,
	T_Double,
} opcua_dt;


struct opcua_device
{
	string url;
	wa_plugin_device_info_t* plugin_cfg;
	UA_Client* dc;
};

extern opcua_device* g_opcua_devices[MAX_OPCUA_DEVICE];
extern void opcua_Get(restful_request_t* request, REQ_ENV_HANDLE req_env);
extern void opcua_Put(restful_request_t* request, REQ_ENV_HANDLE req_env);
extern bool load_device_config(const char* plugin_name);
extern void open_opcua_device(opcua_device* device);

#endif 
